<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>居民区党组织基本信息</title>
<link href="/djzx/css/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/djzx/js/jquery-1.8.1.min.js"></script>
<script language="JavaScript" type="text/javascript" src="/djzx/js/backPage/clientSideApp.js"></script>
<script language="javascript">

$(document).ready(function(){
	$('#generalPartyKey').val('${communityParty.communityGeneralParty.timeKey}');
});

function goback(){
	window.location.href="/djzx/CommunityPartyAction!getPartyInfoListForPage.action";
}

function updateParty(){
	var timeKey = $.trim($('#timeKey').val());
	var name = $.trim($('#name').val());
	var address = $.trim($('#address').val());
	var tel = $.trim($('#tel').val());
	var secretary = $.trim($('#secretary').val());
	var tel1 = $.trim($('#tel1').val());
	var director = $.trim($('#director').val());
	var tel2 = $.trim($('#tel2').val());
	var generalPartyKey = $.trim($('#generalPartyKey').val());
	
	if(name==""){
		alert("党组织名称不能为空");
		return;
	}
	if(address==""){
		alert("地址不能为空");
		return;
	}
	if(tel==""){
		alert("居委会电话不能为空");
		return;
	}
	if(secretary==""){
		alert("党支部书记不能为空");
		return;
	}
	if(tel1==""){
		alert("党支部书记联系方式不能为空");
		return;
	}
	if(director==""){
		alert("居委会主任不能为空");
		return;
	}
	if(tel2==""){
		alert("居委会主任联系方式不能为空");
		return;
	}
	
	var fd = new FormData();
	fd.append('communityParty.timeKey',timeKey);
	fd.append('communityParty.name',name);
	fd.append('communityParty.address',address);
	fd.append('communityParty.tel',tel);
	fd.append('communityParty.secretary',secretary);
	fd.append('communityParty.tel1',tel1);
	fd.append('communityParty.director',director);
	fd.append('communityParty.tel2',tel2);
	fd.append('communityParty.communityGeneralParty.timeKey',generalPartyKey);
	
	$.ajax({
	    url:"${pageContext.request.contextPath}/CommunityPartyAction!updatePartyInfo.action",
	    type:"POST",
	    data:fd,
	    dataType: "json", 
	    contentType: false, //必须
	    processData: false, //必须
	    success:function(data){
	    	alert(data.message);
			if(data.success){
				location.href="/djzx/CommunityPartyAction!getPartyInfoListForPage.action";
			}
	    }
	}); 
}

</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="25" align="center" valign="bottom" class="td06"><table width="98%" border="0" cellspacing="3" cellpadding="0">
      <tr>
        <td width="15"><img src="/djzx/images/index_32.gif" width="9" height="9"></td>
        <td valign="bottom" class="title">编辑党组织</td>
      </tr>
    </table></td>
  </tr>
</table>
<br>
<input type="hidden" name="timeKey" id="timeKey" value="${communityParty.timeKey }" />
<table align="center" width="95%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="120" height="24" class="td_form01">党组织名称</td>
        <td nowrap class=td_form02>
        	<input type="text" name="name" id="name" size="30" value="${communityParty.name }" />
        </td>
        <td width="120" class="td_form01">地址</td>
        <td nowrap class=td_form02>
        	<input type="text" name="address" id="address" size="30" value="${communityParty.address }" />
        </td>
      </tr>
      <tr>
        <td height="24" class="td_form01">居委会电话</td>
        <td nowrap class=td_form02>
        	<input type="text" name="tel" id="tel" size="30" value="${communityParty.tel }" />
        </td>
        <td class="td_form01">党支部书记</td>
        <td nowrap class=td_form02>
        	<input type="text" name="secretary" id="secretary" size="30" value="${communityParty.secretary }" />
        </td>
      </tr>
	  <tr>
        <td height="24" class="td_form01">党支部书记联系方式</td>
        <td nowrap class=td_form02>
        	<input type="text" name="tel1" id="tel1" size="30" value="${communityParty.tel1 }" />
        </td>
        <td class="td_form01">居委会主任</td>
        <td nowrap class=td_form02>
        	<input type="text" name="director" id="director" size="30" value="${communityParty.director }" />
        </td>
      </tr>
	  <tr>
		<td class="td_form01">居委会主任联系方式</td>
        <td nowrap class=td_form02>
        	<input type="text" name="tel2" id="tel2" size="30" value="${communityParty.tel2 }" />
        </td>
        <td class="td_form01">党总支名称</td>
        <td nowrap class=td_form02>
        	<select name="generalPartyKey" id="generalPartyKey">
        	  <s:iterator value="communityGeneralPartyList" var="c" status="statu">
        	  	<option value="${c.timeKey }">${c.name }</option>
        	  </s:iterator>
      		</select>
        </td>
      </tr>
</table>
<br>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center"><input name="Submit2" type="submit" class="buttonface" value="  保存  " onClick="updateParty()">
    <input name="Submit" type="submit" class="buttonface" value="  返回  "  onClick="goback()"></td>
  </tr>
</table>
<br>
</body>
</html>